package runtime.demo2;

import java.lang.reflect.Field;

public class TestRun {
    public static void main(String[] args) {
        getInfo(Apple.class);
    }

    public static void getInfo(Class<?> clazz) {
        String name = "";
        String color = "";
        String provider = "";

        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            if(field.isAnnotationPresent(FruitName.class)) {
                FruitName arg0 = field.getAnnotation(FruitName.class);
                name = name + arg0.value();
                System.out.println(name);
            }

            if(field.isAnnotationPresent(FruitColor.class)) {
                FruitColor arg0 = field.getAnnotation(FruitColor.class);
                color = color + arg0.fruitColor();
                System.out.println(color);
            }

            if(field.isAnnotationPresent(FruitProvider.class)) {
                FruitProvider arg0 = field.getAnnotation(FruitProvider.class);
                provider = provider  + "[id=" + arg0.id() + ",name=" + arg0.name() + ",address=" + arg0.address() + "]";
                System.out.println(provider);
            }
        }
    }
}
